<% @main_header = "#{link_to('Ptrack:', '/')} #{@project.name} : #{@task.name}" %>
<%= display_messages_for_all %>
<div class="column span-24">
  <div class="span-8">
    <% form_for :task, :url => {:action => 'change_status', :id => @task,
      :project_id => @project} do |f| %>
      <%= f.label 'description', 'Reason for status change:' %>
      <br/>
      <% fields_for :task_status_history do |detail| %>
        <%= detail.text_area :description, :style => "height: 60px; width: 234px" %>
      <% end %>
      <%= submit_tag 'Change status to' %>
      <%= select 'task', 'status', @status.each {|value| [value, value]},
        {:selected => @task.status } %>
      <br/>
    <% end %>
  </div>
  <div class="span-8">
    <h4><%= can_enter_working_unit?(@task.status) ?
        "<b>Input new working hour</span></b>" :
        "<span style=\"color:gray\">Input new working hour (disabled)</span>" %></h4>
      <%= "<div class='error' style='width:56%;'>Please provide a valid number for hour(s) \
      </div>" if params[:error] == 'num' %>
      <%= "<div class='error' style='width:56%;'>" + params[:error_message].to_s +
        "</div>" if params[:error] == 'max' %>
      <% form_for :work_unit, :url => {:action => 'new_work',
        :project_id => @project} do |f| %>
        <%= select("user", "id", @people) %> <%= f.label 'Worked for' %>
        <%= f.text_field :amount, :size => '5' %> <b>hrs</b><br /> on
        <%= f.text_field :worked_at, :size => 10 %>
        <%= hidden_field :work_unit, :task_id %>
        <%= submit_tag 'Submit' if can_enter_working_unit?(@task.status) %>
      <% end %>
  </div>
  <div class="span-6" style="display:inline">
    <h4><b>
        <%= '<img title="' + @task.status.to_s + '" src="/images/' +
          @task.status.to_s.downcase.tr(' ', '') +
          '.png" alt="' + @task.status.to_s  + '" />' %>
        <%= @task.name %></b></h4>
    <ul>
      <li><strong>Total Working Hours: </strong>
      <%= over_estimate(@task.projected_time,@total_working_hours) %></li>
      <li><strong>Total Working Hours In Revision: </strong>
      <%= @task.total_working_hours_in_revision %></li>
      <li><strong>Estimated Working Hours: </strong><%= @task.projected_time.blank? ?
        '' : @task.projected_time %></li>
      <li><strong>Expected Start Date: </strong><%= @task.start_date.blank? ?
        '' : @task.start_date.strftime('%d %b %Y')%></li>
      <li><strong>Due Date: </strong><%= @task.end_date.blank? ?
        '' : @task.end_date.strftime('%d %b %Y')%></li>
      <li><strong>End Date: </strong><%= @task.status != 'Approved' ?
          "Task Not Completed" : (@task.end_date.strftime('%d %b %Y') unless
          @task.end_date.blank?) %></li>
      <li><strong>Actual Cost:</strong> <%= @task.total_working_cost.blank? ?
        '' : @task.total_working_cost %> TL</li>
      <li><strong>Assigned to: </strong><%= @assigned_user.blank? ?
        '' : @assigned_user.login %></li>
      <li><strong>Description:</strong> <%= @task.description.blank? ?
        '' : @task.description %></li>
      <li><strong>Keywords: </strong><%= @task.keywords.blank? ?
        '' : @task.keywords %></li>
      <li><strong>Phase: </strong><%= @task.activity.blank? ?
          '' : link_to(@task.activity.phase.name,
          project_activity_url(@task.activity.project_id, @task.activity)) %></li>
      <li><strong>Related Document: </strong><%= @task.document.blank? ?
        '' : @task.document %></li>
      <li><%=  link_to "Task status history", :controller => 'task_status_histories',
          :action => 'index', :task_id => params[:id] %>
      </li>
    </ul>
  </div>
  <div id="daily_activity" class="span-15" style="display:inline; margin-top: -100px">
    <% unless @activity_logs.blank? %>
      <h4><b>Latest Activity</b></h4>
      <ul>
        <% for activity in @activity_logs do %>
            <li> <%#= activity.created_at.strftime('%d %b, %Y %H:%M') %>

              <div><%= activity.description %>
                <%#= link_to "Edit", :action => :edit, :activity_id => activity %>
                <%= link_to "Delete", {:action => "destroy", :activity_id =>
                    activity}, :method => :delete,
                  :confirm => "Are you sure want to delete activity ?" %> </div>
            </li>
          <% end %>
        <% end %>
      </ul>
    </div>
  </div>